# Copyright (c) SandboxAQ. All rights reserved.
# SPDX-License-Identifier: AGPL-3.0-only

load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//proto/protobuf:defs.bzl", "rust_proto_library")

proto_library(
    name = "errors_proto",
    srcs = ["errors.proto"],
    visibility = ["//:__subpackages__"],
)

proto_library(
    name = "tunnel_proto",
    srcs = ["tunnel.proto"],
    visibility = ["//:__subpackages__"],
)

proto_library(
    name = "io_proto",
    srcs = ["io.proto"],
    visibility = ["//:__subpackages__"],
)

proto_library(
    name = "tracing_proto",
    srcs = ["tracing.proto"],
    visibility = ["//:__subpackages__"],
)

proto_library(
    name = "sandwich_proto",
    srcs = ["sandwich.proto"],
    visibility = [
        "//visibility:public",
    ],
    deps = [
        ":errors_proto",
        ":io_proto",
        ":tracing_proto",
        ":tunnel_proto",
    ],
)

##################
# Python library #
##################

py_proto_library(
    name = "errors_python_proto",
    srcs = ["errors.proto"],
    visibility = ["//:__subpackages__"],
)

py_proto_library(
    name = "tunnel_python_proto",
    srcs = ["tunnel.proto"],
    visibility = ["//:__subpackages__"],
)

py_proto_library(
    name = "io_python_proto",
    srcs = ["io.proto"],
    visibility = ["//:__subpackages__"],
)

py_proto_library(
    name = "tracing_python_proto",
    srcs = ["tracing.proto"],
    visibility = ["//:__subpackages__"],
)

py_proto_library(
    name = "sandwich_python_proto",
    srcs = ["sandwich.proto"],
    visibility = ["//:__subpackages__"],
    deps = [
        ":errors_python_proto",
        ":io_python_proto",
        ":tunnel_python_proto",
    ],
)

##############
# Go library #
##############

go_proto_library(
    name = "sandwich_go_proto",
    importpath = "github.com/sandbox-quantum/sandwich/go/proto/sandwich",
    protos = [
        ":errors_proto",
        ":io_proto",
        ":sandwich_proto",
        ":tracing_proto",
        ":tunnel_proto",
    ],
    visibility = ["//visibility:public"],
)

################
# Rust library #
################

rust_proto_library(
    name = "sandwich_rust_proto",
    crate_name = "sandwich_proto",
    rustc_flags = [
        "-A",
        "ambiguous_glob_reexports",
    ],
    visibility = ["//:__subpackages__"],
    deps = [
        ":sandwich_proto",
    ],
)

rust_proto_library(
    name = "tracing_rust_proto",
    crate_name = "tracing_proto",
    rustc_flags = [
        "-A",
        "ambiguous_glob_reexports",
    ],
    visibility = ["//:__subpackages__"],
    deps = [
        ":tracing_proto",
    ],
)

###############
# C++ library #
###############

cc_proto_library(
    name = "sandwich_cc_proto",
    visibility = ["//visibility:public"],
    deps = [
        ":sandwich_proto",
    ],
)
